home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0138_ANIVGA Fades - Fixes.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  6KB  |  180 lines

  1. (*
  2. > Here are some ANIVGA v1.2 fades I am releasing to public domain:
  3. > { FEB-01-94 Added more FadeIn routines: Curtains, Blinds.  MaxFade CONST. }
  4.   As  I posted some time ago, there's a bug in the GetImage() routine in
  5.   V1.2  (which  can  easily  be  fixed by adding "dec(x1,StartVirtualX);
  6.   dec(y1,StartVirtualY);  dec(x2,StartVirtualX); dec(y2,StartVirtualY);"
  7.   at the beginning of the GetImage() procedure).
  8.   If you did so, you can code your fade's kernel as follows:
  9.  
  10.   kai.rohrbacher@logo.ka.sub.org
  11. *)
  12.  
  13. PROCEDURE SweepOutVertical(pa, time: WORD; seam: BOOLEAN);    {JH New! }
  14. { in: pa    = page, which contents will be made visible }
  15. {     time  = time (in milliseconds) for this action (approx.) }
  16. {     seam  =TRUE/FALSE for: show curtain seam in actual drawing color}
  17. {     color =seam color (if seam=TRUE)}
  18. {     1-PAGE= (visible) graphic page on which to draw }
  19. {out: - }
  20. {rem: the contents of page "pa" has been copied to page 1-PAGE }
  21. CONST n=Succ(YMAX);      {number of executions of the delay loop }
  22.       centerY = YMAX DIV 2; {middle of screen }
  23. VAR y, counter: WORD;
  24.     ClockTicks: LONGINT ABSOLUTE $40:$6C;
  25.     t: LONGINT;
  26.     temp: REAL;
  27.     p1: POINTER;
  28.     p2: POINTER;
  29. BEGIN {SweepOutVertical}
  30.  t := ClockTicks;
  31.  counter := 0;
  32.  temp := 0.0182*time/n;
  33.  
  34.  {upward }
  35.  FOR y := centerY DOWNTO 0 DO
  36.   BEGIN
  37.    IF seam
  38.     THEN BEGIN
  39.           Line(StartVirtualX,y+StartVirtualY,
  40.                StartVirtualX+XMAX,y+StartVirtualY,1-PAGE);
  41.            {downward }
  42.           Line(StartVirtualX,YMAX-y+StartVirtualY,
  43.                StartVirtualX+XMAX,YMAX-y+StartVirtualY,1-PAGE);
  44.          END;
  45.    INC(counter);
  46.    WHILE (ClockTicks < (t+counter*temp)) DO BEGIN END;
  47.  {upward }
  48.    p2 := GetImage(StartVirtualX,y+StartVirtualY,
  49.                   StartVirtualX+XMAX,y+StartVirtualY,pa);
  50.    PutImage(StartVirtualX,y+StartVirtualY,p2,1-PAGE);
  51.    FreeImageMem(p2);
  52.  {downward }
  53.    p1 := GetImage(StartVirtualX,YMAX-y+StartVirtualY,
  54.                   StartVirtualX+XMAX,YMAX-y+StartVirtualY,pa);
  55.    PutImage(StartVirtualX,YMAX-y+StartVirtualY,p1,1-PAGE);
  56.    FreeImageMem(p1);
  57.   END;
  58. END;  {SweepOutVertical}
  59.  
  60. PROCEDURE SweepOutHorizontal(pa, time: WORD; seam: BOOLEAN);  {JH New! }
  61. { in: pa    = page, which contents will be made visible }
  62. {     time  = time (in milliseconds) for this action (approx.) }
  63. {     seam  =TRUE/FALSE for: show curtain seam in actual drawing color}
  64. {     color =seam color (if seam=TRUE)}
  65. {     1-PAGE= (visible) graphic page on which to draw }
  66. {out: - }
  67. {rem: the contents of page "pa" has been copied to page 1-PAGE }
  68. CONST n = Succ(XMAX);      {number of executions of the delay loop }
  69.       centerX = XMAX DIV 2; {middle of screen }
  70. VAR x, counter: WORD;
  71.     ClockTicks: LONGINT ABSOLUTE $40:$6C;
  72.     t: LONGINT;
  73.     temp: REAL;
  74.     p1: POINTER;
  75.     p2: POINTER;
  76. BEGIN {SweepOutHorizontal}
  77.  t := ClockTicks;
  78.  counter := 0;
  79.  temp := 0.0182*time/n;
  80.  
  81.  {right_to_left }
  82.  FOR x := centerX DOWNTO 0 DO
  83.   BEGIN
  84.    IF seam
  85.     THEN BEGIN
  86.           Line(x+StartVirtualX,StartVirtualY,
  87.                x+StartVirtualX,StartVirtualY+YMAX,1-PAGE);
  88.           {left_to_right }
  89.           Line(XMAX-x+StartVirtualX,StartVirtualY,
  90.                XMAX-x+StartVirtualX,StartVirtualY+YMAX,1-PAGE);
  91.          END;
  92.    INC(counter);
  93.    WHILE (ClockTicks < (t+counter*temp)) DO BEGIN END;
  94.  {right_to_left }
  95.    p2 := GetImage(x+StartVirtualX,StartVirtualY,
  96.                   x+StartVirtualX,StartVirtualY+YMAX,pa);
  97.    PutImage(x+StartVirtualX,StartVirtualY,p2,1-PAGE);
  98.    FreeImageMem(p2);
  99.  {left_to_right }
  100.    p1 := GetImage(XMAX-x+StartVirtualX,StartVirtualY,
  101.                   XMAX-x+StartVirtualX,StartVirtualY+YMAX,pa);
  102.    PutImage(XMAX-x+StartVirtualX,StartVirtualY,p1,1-PAGE);
  103.    FreeImageMem(p1);
  104.   END;
  105. END;  {SweepOutHorizontal}
  106.  
  107. ...and they will work with any (StartVirtualX,StartVirtualY) values.
  108. (I  omitted  the "color:=white" stuff so that the seam is drwan in the
  109. actual drawing color).
  110.  
  111.  
  112. BTW:  As we are talking about fades, here's another one, check it out!
  113. With  this one, the picture creeps out from the middle line to the top
  114. and bottom (as if you look at an image folded at its middle line which
  115. becomes opened slowly).
  116. I  saw  that one in the opening sequence of EPIC's OVERKILL, and found
  117. it looks nice.
  118.  
  119. PROCEDURE VerticalExpand(pa,time:WORD);
  120. { in: pa    = page, which contents will be made visible }
  121. {     time  = time (in milliseconds) for this action (approx.) }
  122. {out: - }
  123. {rem: the contents of page "pa" has been copied to page visualPage }
  124. CONST n = (YMAX+1)*(YMAX+1) DIV 8; {number of executions of the delay loop}
  125. VAR ClockTicks:^LONGINT; {LONGINT ABSOLUTE $40:$6C geht nicht}
  126.     t: LONGINT;
  127.     temp,mitte,step,akku:REAL;
  128.     lines,y:INTEGER;
  129.  
  130.  PROCEDURE CopyLine(von,nach:WORD);
  131.  { in: von = zu kopierende Zeile von Seite pa}
  132.  {     nach= Zielzeile in Seite visualPage dafuer}
  133.  VAR p1:POINTER;
  134.  BEGIN
  135.   p1 := GetImage(StartVirtualX,von+StartVirtualY,
  136.                  StartVirtualX+XMAX,von+StartVirtualY,pa);
  137.   PutImage(StartVirtualX,nach+StartVirtualY,p1,visualPage);
  138.   FreeImageMem(p1);
  139.  END;
  140.  
  141. BEGIN
  142.  ClockTicks:=Ptr(Seg0040,$6C);
  143.  t := ClockTicks^;
  144.  counter := 0;
  145.  temp := 0.0182*time/n;
  146.  
  147.  mitte:=YMAX/2;
  148.  FOR lines:=1 TO ((YMAX+1) SHR 1)-1 DO
  149.   BEGIN
  150.    step:=YMAX/(lines SHL 1);
  151.    akku:=step;
  152.    FOR y:=0 TO lines-1 DO
  153.     BEGIN
  154.      CopyLine(TRUNC(mitte-akku),(YMAX+1) SHR 1 -y-1);
  155.      CopyLine(TRUNC(mitte+akku),(YMAX+1) SHR 1 +y);
  156.      akku:=akku+step;
  157.      INC(counter);
  158.      WHILE (ClockTicks^ < (t+counter*temp)) DO BEGIN END;
  159.     END;
  160.   END;
  161.  
  162.  {Cleanup:}
  163.  lines:=YMAX SHR 1;
  164.  FOR y:=0 TO YMAX SHR 1 DO
  165.   BEGIN
  166.    CopyLine( lines-y,lines-y);
  167.    CopyLine( lines+y,lines+y);
  168.    INC(counter);
  169.    WHILE (ClockTicks^ < (t+counter*temp)) DO BEGIN END;
  170.   END;
  171.  IF Odd(YMAX)
  172.   THEN CopyLine(YMAX,YMAX);
  173. END;
  174. {
  175.   I  gave  it  the fade constant "Fade_VerticalExpand=29", so in routine
  176.   FadeIn() extend the CASE clause by:
  177.      Fade_VerticalExpand: VerticalExpand(pa,ti);
  178. }
  179.  
  180.